public class Main {
    public static int solution(int a, int b) {
        String aStr = String.valueOf(a);
        String bStr = String.valueOf(b);
        int max = Integer.MIN_VALUE;

        for (int i = 0; i <= aStr.length(); i++) {
            String newStr = aStr.substring(0, i) + bStr + aStr.substring(i);
            int num = Integer.parseInt(newStr);
            if (num > max) {
                max = num;
            }
        }

        return max;
    }

    public static void main(String[] args) {
        System.out.println(solution(76543, 4) == 765443);
        System.out.println(solution(1, 0) == 10);
        System.out.println(solution(44, 5) == 544);
        System.out.println(solution(666, 6) == 6666);
        System.out.println(solution(17, 1) == 171);
    }
}
